//----------------------------------------------------------------------------
// M A R I T I M E  R E S E A R C H  I N S T I T U T E  N E T H E R L A N D S
//----------------------------------------------------------------------------
// Copyright (C) 2012 - MARIN - All rights reserved - http://www.marin.nl
//----------------------------------------------------------------------------
// Program    : mermaid
// Module     : vbm
// File       : smoothzetaphi_kernels.h
// Author     : M.A. de Jong
//----------------------------------------------------------------------------

#ifndef SMOOTHZETAPHI_KERNELS_H
#define SMOOTHZETAPHI_KERNELS_H

#ifdef USEDOUBLE
#define ONE 1.0
#else
#define ONE 1.0f
#endif

namespace wavescomputer
{

template <class T>
__global__ void kernel_smoothzetaphi(T* dt_phi,
                                     T* dt_zeta,
                                     const T* dt_phim1,
                                     const T* dt_zetam1,
                                     const T eps,
                                     const int ld)
{
    int u = bx * Bx + tx;
    int v = by * By + ty;
    int tid = v * ld + u;

    const T eps_minus = ONE - eps;

    dt_zeta[tid] = eps_minus * dt_zeta[tid] + eps * dt_zetam1[tid];
    dt_phi [tid] = eps_minus * dt_phi [tid] + eps * dt_phim1 [tid];
}

} // namespace wavescomputer

#endif // SMOOTHZETAPHI_KERNELS_H

